/**  

* @Title: AdministratorDaoHibernate.java 

* @Package com.gxbadge.dao.impl 

* @Description: TODO(用一句话描述该文件做什么) 

* @author CST

* @version V1.0  

*/ 

package com.gxbadge.dao.impl;

import java.util.List;

import com.gxbadge.dao.AdministratorDao;
import com.gxbadge.dao.base.BaseHibernateDaoSupport;
import com.gxbadge.model.Administrator;

public class AdministratorDaoHibernate extends BaseHibernateDaoSupport implements AdministratorDao {

	/* 
	 * {见接口方法说明}
	 */
	public void delete(Administrator admin) {
		
		this.getHibernateTemplate().delete(admin);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public List<Administrator> findAdminAll() {
		
		List<Administrator> adminList = this.getHibernateTemplate().find("from Administrator");
		if(adminList!=null&&adminList.size()>=1){
			return adminList;
		}
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public Administrator findAdminByAdminId(Integer adminId) {
		
		Administrator admin = this.getHibernateTemplate().get(Administrator.class, adminId);
		if(admin!=null){
			return admin;
		}
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public Administrator findAdminByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public Administrator findAdminByNameAndPassword(String name, String password) {
		
		List<Administrator> adminList = this.getHibernateTemplate().find("from Administrator as a where a.name=? and a.password=?",name, password);
		if(adminList!=null&&adminList.size()==1){
			Administrator admin = adminList.get(0);
			if(admin!=null){
				return admin;
			}
		}
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public void save(Administrator admin) {
		
		this.getHibernateTemplate().save(admin);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public void update(Administrator admin) {
		
		this.getHibernateTemplate().update(admin);
		
	}

}
